{/* LAYOUT模板 */}
	<layout name="layout"/>
{/* LAYOUT模板 */}
{/* import Js,Css */}
	<js href="__PUBLIC__/js/admin/listTable.js"/>
	<js href="__PUBLIC__/js/admin/js.util.js"/>
	<css href="__PUBLIC__/css/admin/common.css"/>
	<js href="__PUBLIC__/js/admin/js.selectzone.js"/>
	
	<css href="__PUBLIC__/css/jquery-ui.css" />
	<js href="__PUBLIC__/js/core/jquery-ui.1.10.4.js" />
	<js href="__PUBLIC__/js/core/plugins.js"/>
{/* import js,css */}
<!-- [position] -->
	<include file="Template:position"/>
<!-- [position] -->

<div class="main-div">
	<form action="__URL__/{$action}" method="post" name="theForm" onsubmit="return validate()">
		<table width="100%">
			<tr>
				<td class="label" align="right">会员等级名称: </td>
				<td><input type="text" name="rank_name" value="{$rank.rank_name}" maxlength="20" />{$lang.require_field}</td>
			</tr>
			<tr>
				<td class="label" align="right">积分下限: </td>
				<td><input type="text" name="min_points" value="{$rank.min_points}" size="10" maxlength="20" /></td>
			</tr>
			<tr>
				<td class="label" align="right">积分上限: </td>
				<td><input type="text" name="max_points" value="{$rank.max_points}" size="10" maxlength="20" /></td>
			</tr>
			<tr>
				<td class="label" align="right"></td>
				<td>
					<input type="checkbox" name="show_price" value="1" {if $rank.show_price eq 1} checked="true"{/if} />
					在商品详情页显示该会员等级的商品价格
				</td>
			</tr>
			<tr>
				<td class="label" align="right"></td>
				<td>
					<input type="checkbox" name="special_rank" value="1" <if condition="$rank['special_rank'] eq 1">checked="true"</if> onClick="javascript:doSpecial()" /> 
					特殊会员组 
					<a href="javascript:showNotice('notice_special');" title="点击此处查看提示信息 ">
						<img src="__PUBLIC__/Image/admin/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}">
					</a>
					<br/>
					<span class="notice-span" <if condition="$help_open">style="display:block"<else/>style="display:none"</if> id="notice_special">
						特殊会员组的会员不会随着积分的变化而变化。
					</span>
				</td>
			</tr>
			<tr>
				<td class="label" align="right">
					<a href="javascript:showNotice('notice_discount');" title="{$lang.form_notice}">
						<img src="__PUBLIC__/Image/admin/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}">
					</a>
					初始折扣率:
				</td>
				<td>
					<input type="text" name="discount" value="{$rank.discount}" size="10" maxlength="20" />{$lang.require_field}
					<br/>
					<span class="notice-span" <if condition="$help_open">style="display:block"<else/>style="display:none"</if> id="notice_discount">
						请填写为0-100的整数,如填入80，表示初始折扣率为8折
					</span>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
				<input type="hidden" name="act" value="{$form_action}" />
				<input type="hidden" name="id" value="{$rank.rank_id}" />
				<input type="submit" value="提交" />
				<input type="reset" value="重置" />
				</td>
			</tr>
		</table>
	</form>
</div>


<script language="JavaScript">
	document.forms['theForm'].elements['rank_name'].focus();
	onload = function(){
	  // 开始检查订单
	  // startCheckOrder();
	}
	/**
	 * 检查表单输入的数据
	 */
	function validate(){
		if (!document.forms['theForm'].elements['special_rank'].checked){
			if (Utils.trim(document.forms['theForm'].elements['min_points'].value) == '' ||
				!Utils.isInt(document.forms['theForm'].elements['min_points'].value)){
				alert(integral_min_invalid);
				return false;
			}
			if (Utils.trim(document.forms['theForm'].elements['max_points'].value) == '' ||
				!Utils.isInt(document.forms['theForm'].elements['max_points'].value)){
				alert(integral_max_invalid);
				return false;
			}
			if (!document.forms['theForm'].elements['special_rank'].checked &&
				(parseInt(document.forms['theForm'].elements['max_points'].value) <=
				parseInt(document.forms['theForm'].elements['min_points'].value))){
				alert(integral_max_small);
				return false;
			}
			if (parseInt(document.forms['theForm'].elements['discount'].value) < 1 ||
			  parseInt(document.forms['theForm'].elements['discount'].value) > 100){
			  alert(discount_invalid);
			  return false;
			}
		}

		validator = new Validator("theForm");
		validator.required('rank_name', rank_name_empty);
		validator.isInt('discount', discount_invalid, true);
		return validator.passed();
	}
	function doSpecial(){
	  if(document.forms['theForm'].elements['special_rank'].checked){
		  document.forms['theForm'].elements['max_points'].disabled = "true";
		  document.forms['theForm'].elements['min_points'].disabled = "true";
	  }
	  else{
		  document.forms['theForm'].elements['max_points'].disabled = "";
		  document.forms['theForm'].elements['min_points'].disabled = "";
	  }
	}

</script>






